package com.chinawayltd.ews.sample.util;


import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * @program: greeProject
 * @description 
 * @author: chenxin
 * @create: 2018年4月25日 上午10:57:48
 */
public class MapUtils{
	
	public static Map<String, Object> objectToMap(Object obj) throws IllegalAccessException {
		Map<String, Object> map = new HashMap<>();
		Class<?> clazz = obj.getClass();
		System.out.println(clazz);
		for (Field field : clazz.getDeclaredFields()) {
			field.setAccessible(true);
			String fieldName = field.getName();
			Object value = field.get(obj);
			map.put(fieldName, value);
		}
		return map;
	}
	
}
